import { statisticParamTypeApi } from '../../api/statistic'
import { typeOptions } from '../typeOption'

const initOption = () => {
  return {
    title: {
      text: '本周异常数据参数占比',
      top: '5%'
    },
    radar: {
      axisName: {
        formatter: '{value}',
        color: '#000'
      }
    }
  }
}
const apdaterOption = (dom) => {
  const titleFontSize = (dom.offsetWidth / 100) * 2.5
  return {
    title: {
      textStyle: {
        fontSize: titleFontSize
      }
    }
  }
}
const dataOption = async (teamId) => {
  const { data: res } = await statisticParamTypeApi(teamId)
  const indicator = []
  const value = []
  for (const type in typeOptions) {
    indicator.push({ name: typeOptions[type].label })
    value.push(res.data[type] ? res.data[type] : 0)
  }
  return {
    radar: {
      indicator: indicator
    },
    series: [
      {
        type: 'radar',
        areaStyle: {},
        data: [
          {
            value: value,
            label: {
              show: true
            }
          }
        ]
      }
    ]
  }
}

export { initOption, apdaterOption, dataOption }
